import React, { Component } from 'react'
import PropTypes from 'prop-types'

// let {
  // string,
  // number,
  // element,
  // instanceOf,
  // node,
  // oneOf,
  // oneOfType,
  // arrayOf,
  // objectOff,
  // shape,
  // exact
// } = PropTypes

// class AAA extends Component {
//   render() {
//     return (
//       <div>aaa</div>
//     )
//   }
// }

// const aaa = new AAA()

class Child extends Component {
  static propTypes = {
    // title: PropTypes.string
    // title: instanceOf(AAA)
    // title: node,
    // title: shape({
    //   gender: string,
    //   name: string,
    //   age: number.isRequired
    // })

    title(props, propName, componentName) {
      console.log(props, propName, componentName)
      if (props.title === 'hello') {

      } else {
        return new Error()
      }
    }
  }
  render() {
    console.log(this.props.title)
    return (
      <>
        {/* <div>child { this.props.title }</div> */}
        <div>child { this.props.title.name }</div>
      </>
    )
  }
}


export default class PropType extends Component {
  render() {
    return (
      <div>
        {/* <Child title="hello"></Child> */}
        {/* <Child title={0}></Child> */}
        {/* <Child title={<div>aaa</div>}></Child> element*/}
        {/* <Child title={<AAA />}></Child> */}
        {/* <Child title={{name: 'zhangshan', age: 12}}></Child> */}
        <Child title='hello'></Child>
      </div>
    )
  }
}